import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:zywz/pages/report/Income_statement.dart';

import '../../bloc/report/report_bloc.dart';
import '../../bloc/report/report_data.dart';
import '../../widgets/EmptyPlaceholder.dart';

class BlanceQyzwTax extends StatefulWidget {

  final String title;
  final String type;
  const BlanceQyzwTax({super.key, required this.title, required this.type});

  @override
  State<BlanceQyzwTax> createState() => _BlanceQyzwTaxState();
}

class _BlanceQyzwTaxState extends State<BlanceQyzwTax> with  AutomaticKeepAliveClientMixin {
  @override
  bool get wantKeepAlive => true;



  @override
  Widget build(BuildContext context) {
    return  BlocConsumer<ReportBloc, ReportState>(
        buildWhen: (previous, current) {
          if (current is ReportBalanceQyZwReportSuccess) {
            return true;
          }
          return false;
        },
        listener: (context, state) {
          if (state is ReportLoadFailure) {

          }
        },
        builder: (context, state) {
          if (state is ReportBalanceQyZwReportSuccess) {
            var mSize = state.reportData.length;
            if(mSize == 0){
              return Center(child: EmptyPlaceholder(message: '暂无负债数据'));
            }
            return SingleChildScrollView(
              child: Container(
                margin: const EdgeInsets.symmetric(horizontal: 0.0),
                padding: const EdgeInsets.all(0.0),
                decoration: BoxDecoration(
                  color: Colors.white,

                  boxShadow: [
                    BoxShadow(
                      color: Colors.grey.withOpacity(0.1),
                      spreadRadius: 1,
                      blurRadius: 5,
                      offset: const Offset(0, 3),
                    ),
                  ],
                ),
                child: Column(
                  // children: taxItems.map((item) => TaxListItem(item: item)).toList(),
                  // children:[...(state.map((item) => TaxListItem(keyItem: '1', valueItem: '2')).toList())],
                  children: state.reportData.map((entry) =>
                      InComeItem( data: entry ,)).toList(), // 注意这里需要 toList()
                  // children: [],
                ),
              ),
            );
          } else {
            return Container();
          }
        });;
  }
}
